import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalFeedback(Base):
    """
     反馈页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.feedback_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.feedback_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 页面_变量名_元素类型
        # 标题图标
        self.feedback_title_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_title_voice"))

        # 标题欢迎语
        self.feedback_title_welcome_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_feedback_title"))
        # self.feedback_title_welcome_text = (By.XPATH, Page.TEXT.format("欢迎来到反馈中心，您反馈的问题我们会尽快为您解决"))

        # 问题1图标
        self.feedback_question_one_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_serial_number_one"))

        # 请选择问题类别文本
        self.feedback_question_one_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_select_category"))
        # self.feedback_select_question_text = (By.XPATH, Page.TEXT.format("请选择问题类别"))

        # 功能使用按钮
        self.feedback_function_btn = (By.XPATH, Personal.RESOURCE_ID.format("qcv_feature_category"))
        # self.feedback_function_btn = (By.XPATH, Page.TEXT.format("功能使用"))

        # 投诉建议按钮
        self.feedback_suggestions_btn = (By.XPATH, Personal.RESOURCE_ID.format("qcv_suggestions"))
        # self.feedback_complaint_btn = (By.XPATH, Page.TEXT.format("投诉建议"))

        # 其他按钮
        self.feedback_other_btn = (By.XPATH, Personal.RESOURCE_ID.format("qcv_other"))
        # self.feedback_other_btn = (By.XPATH, Page.TEXT.format("其它"))

        # 我的消息按钮
        self.feedback_my_news_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_mine_message"))
        # self.feedback_my_news_btn = (By.XPATH, Page.TEXT.format("我的消息"))

        # 问题2图标
        self.feedback_question_two_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_serial_number_two"))

        # 请描述问题文本
        self.feedback_question_two_title_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_question_desc"))
        # self.feedback_question_two_title_text = (By.XPATH, Page.TEXT.format("请描述您的问题"))

        # 语音按钮
        self.feedback_voice_input_btn = (By.XPATH, Personal.RESOURCE_ID.format("frame_voice_input"))

        # 问题输入框
        self.feedback_description_question_input = (By.XPATH, Personal.RESOURCE_ID.format("et_feedback_content"))
        # self.feedback_description_question_input = (By.XPATH, Page.TEXT.format("问题描述大于5小于200字"))

        # 提交按钮
        self.feedback_submit_btn = (By.XPATH, Personal.RESOURCE_ID.format("bt_feedback_post"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.feedback_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.feedback_back_btn)

    def get_title(self):
        """
        获取反馈语音标签

        :return: 获取元素
        """
        return self.find_element_o(self.feedback_title_icon)

    def get_title_welcome(self):
        """
        获取反馈欢迎语

        :return: 获取元素
        """
        return self.find_element_o(self.feedback_title_welcome_text)

    def get_question_one(self):
        """
        获取问题1图标

        :return: 获取元素
        """
        return self.find_element_o(self.feedback_question_one_icon)

    def get_question_one_title(self):
        """
        获取问题1标题

        :return: 获取元素
        """
        return self.find_element_o(self.feedback_question_one_title_text)

    def click_function(self):
        """
        点击功能使用按钮

        :return: None
        """
        self.find_element_o(self.feedback_function_btn)

    def click_suggestions(self):
        """
        点击投诉建议按钮

        :return:NOne
        """
        self.click_element(self.feedback_suggestions_btn)

    def click_other(self):
        """
        点击其他按钮

        :return: None
        """
        self.click_element(self.feedback_other_btn)

    def click_my_news(self):
        """
        点击我的消息按钮

        :return: None
        """
        self.click_element(self.feedback_my_news_btn)

    def get_question_two(self):
        """
        获取问题2的图标

        :return: 获取元素
        """
        return self.find_element_o(self.feedback_question_two_icon)

    def get_question_two_title(self):
        """
        获取问题2的标题

        :return: 获取元素
        """
        return self.find_element_o(self.feedback_question_two_title_text)

    def click_voice_input(self):
        """
        点击语音输入按钮

        :return: None
        """
        self.click_element(self.feedback_voice_input_btn)

    def input_description_question(self, text):
        """
        输入反馈内容

        :param text: 输入文本
        :return:
        """
        self.input_text(self.feedback_description_question_input, text)

    def click_submit(self):
        """
        点击提交按钮

        :return: None
        """
        self.click_element(self.feedback_submit_btn)

    def is_display_personal_feedback(self):
        """
        是否存在反馈界面

        :return: bool
        """
        return self.is_display(self.feedback_title_welcome_text)
